package com.yichen.music;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.yichen.util.ActorsUtils;
import com.yichen.util.MusicUtil;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;

public class Cate_Actor_Name extends ListActivity implements
		OnItemClickListener {
	List<String> actor_name_data;
	List<Map<String, String>> data_base;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		Intent intent = getIntent();
		String cate_actor_TYPE_ID = intent.getStringExtra("actor_TYPE_ID");
		ActorsUtils mm = new ActorsUtils();
		data_base = mm.getActorsByType(cate_actor_TYPE_ID);

		actor_name_data = new ArrayList<String>();

		for (Map<String, String> map : data_base) {
			actor_name_data.add(map.get("actor_NAME"));
		}

		ArrayAdapter<String> data_adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, actor_name_data);

		this.setListAdapter(data_adapter);
		this.getListView().setOnItemClickListener(this);

	}

	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		// TODO Auto-generated method stub
		// System.out.println(data_base.get(arg2).get("actor_ID"));// 获取歌手的ID

		Intent re_intent = new Intent();
		re_intent.putExtra("actor_ID", data_base.get(arg2).get("actor_ID"));// 下一个页面需要id作为查询条件
		re_intent.setClass(this, Actor_Music_List.class);
		startActivity(re_intent);

	}
}
